from django.db import models


'''
    Topic:类名,当我们进行模型迁移之后,会根据类名,自动创建一个表
    models.Model: Django的基类,创建模型继承
'''
class Topics(models.Model):
    # 主键id,自动增加
    id = models.AutoField(primary_key=True)
    # 标题:title,varchar(500)
    title = models.CharField(max_length=5000)
    # 问题概要,长度为40,允许为空
    summary = models.CharField(max_length=40, null=True)
    # status 默认值为1,1为正常,0为删除
    status = models.IntegerField(default=1)
    # 用户id: user_id,int
    user_id = models.IntegerField()
    # 创建时间: create_time,datetime
    create_time = models.DateTimeField(auto_now_add=True)

class Chat(models.Model):
    # 主键id,自动增加
    id = models.AutoField(primary_key=True)
    # 主体id topic_id
    topic_id = models.IntegerField()
    # 用户id: user_id,int
    user_id = models.IntegerField()
    # 角色role user assiant
    role = models.CharField(max_length=10)
    # 内容: content,text,使用utf8mb4_general_ci
    content = models.TextField(db_collation='utf8mb4_general_ci')
    # content = models.TextField()
    # 创建时间: create_time,datetime
    create_time = models.DateTimeField(auto_now_add=True)